/*
 * 百度在线网络技术（北京）有限公司拥有本软件版权2022并保留所有权利。
 * Copyright 2022, Baidu.com,Inc 2:Baidu Online Network Technology (Beijing) Co.,Ltd,
 * All rights reserved.
 */

package com.azdebugit.spring.docother.juc.cow;

import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @author azdebugit
 * Date 2021/7/4
 * @version 1.0
 */
public class CopyOnWriteArrayListTest {
    public static void main(String[] args) {
//        List<String> list = new ArrayList<>();
        //List<String> list = new Vector<>();
        //List<String> list = Collections.synchronizedList(new ArrayList<>());
        List<String> list = new CopyOnWriteArrayList<>();
        
        for (int i = 0; i < 20; i++) {
            new Thread(() -> {
                list.add(UUID.randomUUID().toString().substring(0,5));
                System.out.println(Thread.currentThread().getName() + " : "+list);
            },String.valueOf(i)).start();
        }
    }
}
